import { useRequest } from '@/api/hooks/use-request'
import { ApiResponseData, BaseRequestMethod } from '../request/types'
import { request } from '../request'

const url = '/role'

export interface StaffRoleRequestMethod extends BaseRequestMethod {}

// 公共请求方法
const { getDataList, createData, updateData, deleteData } = useRequest(url)

// 分配权限
const assignPermission = <T = ApiResponseData>(id: number, menuIds: any) => {
  return request.put<T>({
    url: url + '/' + id + '/assign',
    data: { menuIds }
  })
}

export { getDataList, createData, updateData, deleteData, assignPermission }
